package data.socket
{
	import flash.utils.ByteArray;

	public class SocketOut
	{
		private static var _socketBase:SocketBase;
		private var _callBack:Function;
		
		public function SocketOut()
		{
		}
		
		/**
		 * Socket发送类注册 
		 * @param socketBase Socket连接对象
		 * @param callBack 返回方法
		 */		
		public function register(socketBase:SocketBase, callBack:Function):void
		{
			_socketBase=socketBase;
			_callBack=callBack;
			
			if(_callBack!=null) _callBack();
		}
		
		/**
		 * Socket数据包发送 
		 * @param socketPack 数据包
		 */		
		public function sendByteArrayPack(dataPack:ByteArray):void
		{
			if(!_socketBase)
			{
				trace("Socket通讯工厂尚未注册，无法实现通讯");
				return;
			}
			
			_socketBase.sendByteArray(dataPack);
		}
		
		/**
		 * Socket数据包发送 
		 * @param socketPack 数据包
		 */		
		public function sendAMFPack(dataPack:Object):void
		{
			if(!_socketBase)
			{
				trace("Socket通讯工厂尚未注册，无法实现通讯");
				return;
			}
			
			_socketBase.sendAMF(dataPack);
		}
		
		/**
		 *资源释放 
		 */		
		public function dispose():void
		{
			_socketBase=null;
			_callBack=null;
		}
	}
}